package com.chem.lems.repository;


import com.chem.lems.entity.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface RoleRepository extends JpaRepository<Role, String> {

    @Transactional
    @Modifying
    @Query(value = "DELETE FROM elms_role_menu t WHERE t.role_id=?1 AND t.menu_id=?2",nativeQuery = true)
    void deleteRoleRinghtByMenusId(String roleId, int menusId);


    @Transactional
    @Modifying
    @Query(value = "INSERT INTO `elms_role_menu`(`role_id`, `menu_id`) VALUES (?1, ?2)",nativeQuery = true)
    void saveRoleRinght(String roleId, int menusId);
}
